<{include file="Common/head"}>
<{include file="Common/menu"}>

<link href="_index_/yy/index.css" rel="stylesheet">
<link href="_index_/yy/laydate.css" rel="stylesheet">
<script src="_index_/yy/laydate.js"></script>
<script type="text/javascript" src="_index_/laydate/laydate.js"></script>
<style type="text/css">

    .submit,.reset{    cursor: pointer;}
	#test-limit3{  width: 40%;  height: 30px;  padding: 2px 5px;  font-size: 18px;  color: #555;  }
    #test-limit2{    height: 30px;  padding: 2px 5px;  font-size: 18px;  color: #555;  }
    .appointment .physician input{width:15px;height:15px;}
    .appointment .position input{width:15px;height:15px;}
    .colorred{color:red;}
    .phone,.yaoyue{height:40px;}
    .test-5::-webkit-scrollbar {/*滚动条整体样式*/
        width: 10px;     /*高宽分别对应横竖滚动条的尺寸*/
        height: 1px;
    }
    .test-5::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
        border-radius: 10px;
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        background: #ddd;
    }
    .test-5::-webkit-scrollbar-track {/*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        border-radius: 10px;
        background: #fff;
    }
    .time_hour,.time_min{border: solid 1px #eee;}
    .Hui-article-box{ top:15px!important;}
</style>

<section class="Hui-article-box test-5" >
    <form class="appointment">
        <ul>
            <li>
                <h2>预约日期：</h2>
                <div class="laydate-box">
                    <input type="text" id="laydateInputs" value="<{$date}>" disabled/>
                    <div class="select-date">
                        <div class="select-date-header">
                            <ul class="heade-ul">
                                <li class="header-item header-item-one">
                                    <select name="" id="yearList"></select>
                                </li>
                                <li class="header-item header-item-two" onselectstart="return false">
                                    <select name="" id="monthList"></select>
                                </li>
                                <li class="header-item header-item-three" onselectstart="return false">
                                    <span class="reback">回到今天</span>
                                </li>
                            </ul>
                        </div>
                        <div class="select-date-body">
                            <ul class="week-list">
                                <li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li>
                            </ul>
                            <ul class="day-tabel"></ul>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <h2>宏迈号　：</h2>
                <input type="text" autocomplete="off" name="hongmai" class="layui-input input-text hongmai" id="test-limit2" placeholder="宏迈号">
            </li>
            <li>
                <!--
				<h2>时　　间：</h2>
                <input type="text" autocomplete="off" name="time" class="layui-input time" id="test-limit3" placeholder="时:分:秒">
                -->
                <h2>时　　间：</h2>
                <select class="time_hour " name="time_hour" style="width: 30%;font-size: 18px;">
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                </select>
                <select class="time_min select_min" name="time_min" style="width: 30%;font-size: 18px;">
                    <option value="00">00</option>
                    <option value="30">30</option>
                </select>
            </li>
            <li>
                <h2>顾客姓名：</h2>
                <input type="text" autocomplete="off" name="name" class="layui-input name"  placeholder="顾客姓名">
            </li>
            <li>
                <h2>电　　话：</h2>
                <input class="phone input-text" autocomplete="off" name="phone" type="text" placeholder="顾客电话" />
            </li>

            <li>
                <h2>渠　　道：</h2>
                <select class="channel" name="from">
                    <?php
                        foreach($data[5]['value'] as $fk => $fv){
                    ?>
                    <option value="<?php echo $fv; ?>"><?php echo $fv; ?></option>
                    <?php
                        }
                    ?>
                </select>
            </li>
            <li>
                <h2>治疗房间：</h2>
                <select class="channel zhiliaoshi" name="zhiliaoshi">
                    <?php
                        foreach($data[6]['value'] as $fk => $fv){
                    ?>
                    <option value="<?php echo $fv; ?>"><?php echo $fv; ?></option>
                    <?php
                        }
                    ?>
                </select>
            </li>
            <li>
                <h2>邀　　约：</h2>
                <input type="text" name="yaoyue" autocomplete="off" class="input-text yaoyue"  placeholder="邀约人">
            </li>


            <li>
                <h2>医　　生：</h2>
                <div class="physician">
                    <?php
                            foreach($data[4]['value'] as $dk => $dv){
                    ?>
                    <div class="check-box"><input type="checkbox" name="doctor" value="<?php echo $dv; ?>" id="do_<?php echo $dv; ?>"> <label for="do_<?php echo $dv; ?>"><?php echo $dv; ?></label></div>
                    <?php
                        }
                    ?>
                </div>
            </li>

            <li>
                <h2>美容医师：</h2>
                <div class="physician">
                    <?php
                            foreach($data[7]['value'] as $nk => $nv){
                    ?>
                    <div class="check-box"><input type="checkbox" name="meirongshi" value="<?php echo $nv; ?>" id="mr_<?php echo $nv; ?>"> <label for="mr_<?php echo $nv; ?>"><?php echo $nv; ?></label></div>
                    <?php
                            }
                        ?>
                </div>
            </li>

            <li>
                <h2>治疗项目：</h2>
                <div class="position skin-minimal">
                    <?php
                            foreach($data[1]['value'] as $pk => $pv){
                    ?>
                    <div class="check-box"><input type="checkbox" name="position" value="<?php echo $pv; ?>" id="it_<?php echo $pk; ?>"> <label for="it_<?php echo $pk; ?>"><?php echo $pv; ?></label></div>
                    <?php
                            }
                        ?>
                </div>
            </li>

            <li>
                <h2>设　　备：</h2>
                <div class="physician">
                    <?php
                        foreach($data[0]['value'] as $dk => $dv){
                    ?>
                    <div class="check-box">
                        <input type="checkbox" name="device" value="<?php echo str_replace('[error]','',$dv); ?>" id="d_<?php echo $dk; ?>" <?php if(strpos($dv,"[error]")){echo "disabled";} ?>>
                        <label for="d_<?php echo $dk; ?>" class='<?php if(strpos($dv,"[error]")){echo "colorred";} ?>'><?php echo str_replace('[error]','',$dv); ?></label>
                    </div>
                    <?php
                        }
                    ?>
                </div>
            </li>

            <li>
                <h2>预计时长：</h2>
                <select class="lengthtime" name="time_length">
                    <option value="10分钟">10分钟</option>
                    <option value="15分钟">15分钟</option>
                    <option value="20分钟">20分钟</option>
                    <option value="25分钟">25分钟</option>
                    <option value="30分钟">30分钟</option>
                    <option value="40分钟">40分钟</option>
                    <option value="45分钟">45分钟</option>
                    <option value="50分钟">50分钟</option>
                    <option value="1小时">1小时</option>
                    <option value="1.5小时">1.5小时</option>
                    <option value="2小时">2小时</option>
                </select>
            </li>
            <li>
                <h2>备　　注：</h2>
                <textarea class="message" name="message" rows="5"></textarea>
            </li>
			<li><input class="btn btn-success radius submit" type="button" value="添加"></li>
        </ul>
    </form>

</section>
<!--
<?php dd($time); ?>
-->
<script type="text/javascript">
$(function(){

    //设置时间、项目
    $(".position input[value='<?php echo $item; ?>']").attr('checked',true);
    $(".time_hour option[value='<?php echo $time[0]; ?>']").prop("selected","true");
    $(".time_min option[value='<?php echo $time[1]; ?>']").prop("selected","true");

	//限定可选时间
    /*
    laydate.render({
        elem: '#test-limit3'
        ,type: 'time'
        ,min: '09:00:00'
        ,max: '19:00:00'
        ,btns: ['clear', 'confirm']
    });
     */
    $(".reset").click(function() {
        $(".appointment")[0].reset();
        $(".reback").click();
    });

    $(".submit").on("click",function(){

        //治疗项目
        obj = document.getElementsByName("position");
        check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
        //医生
        obj = document.getElementsByName("doctor");
        doctor_val = [];
        for(k in obj){
            if(obj[k].checked)
                doctor_val.push(obj[k].value);
        }

        //设备zhiliaoshi
        obj = document.getElementsByName("device");
        device_val = [];
        for(k in obj){
            if(obj[k].checked)
                device_val.push(obj[k].value);
        }

        //美容师
        obj = document.getElementsByName("meirongshi");
        meirongshi_val = [];
        for(k in obj){
            if(obj[k].checked)
                meirongshi_val.push(obj[k].value);
        }


        if(check_val.length==0){
            alert("治疗项目必选");
            return false;
        }

        if(doctor_val.length==0&&meirongshi_val.length==0){
            alert("治疗人员选项必选");
            return false;
        }
        if(device_val.length==0){
            alert("仪器必选");
            return false;
        }

        date        = $("#laydateInputs").val(); //预约日期
        zhiliaoshi_val= $(".zhiliaoshi").val();
        hongmai     = $(".hongmai").val();        //宏迈号
        //time        = $(".time").val();        //治疗时间 几点钟
        time        = ($(".time_hour").val())+":"+($(".time_min").val());        //治疗时间 几点钟
        name        = $(".name").val();        //顾客姓名
        yaoyue      = $(".yaoyue").val();        //邀约
        channel     = $(".channel").val();        //渠道
        position    = check_val;        //治疗项目
        phone       = $(".phone").val();
        lengthtime  = $(".lengthtime").val();        //预计时长
        doctor      = doctor_val;         //医生
        meirongshi  = meirongshi_val;        //美容师
        device      = device_val;        //设备
        message     = $(".message").val();        //留言



        var postdata = {
            "date":date,
            "hongmai":hongmai,
            "time":time,
            "name":name,
            "yaoyue":yaoyue,
            "phone":phone,
            "channel":channel,
            "position":position,
            "lengthtime":lengthtime,
            "doctor":doctor,
            "meirongshi":meirongshi,
            "device":device,
			"zhiliaoshi":zhiliaoshi_val,
            "message":message
        };

        console.log(postdata);


        $.post("/index/Index/adddata",postdata,function(e){
            if(e==1){
                $.Huimodalalert('提交成功',2000);
                window.close();
            }else if(e=="deny"){
                $.Huimodalalert('无权限进行该操作',1000);
                return false;
            }
        });


    });



    //弹出式添加页面，隐藏左边菜单栏
    if(document.body.clientWidth>760){
        $(".navbar-wrapper").css("display","none");
        $("body").addClass("big-page");
        $(".dislpayArrow").css("display","none");
    }
	
	
	
	



});

function getSelectDate(result){
    console.log(result);
}

</script>
<{include file="Common/footer"}>